package com.baoxin.user.controller;


import com.baoxin.user.pojo.User;
import com.baoxin.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope  // 刷新配置
@Slf4j
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService ;


    @Value("${test.name}")
    private String name ;

    @GetMapping("{id}")
    public User queryById(@PathVariable("id")  Long id ){

       /* try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/
        log.info("配置文件中获取到的值为："+ name);
        return userService.queryById(id);
    }

}
